<template>
  <LowCode :schema="schema"> </LowCode>
</template>

<script setup>
import LowCode from '@/components/LowCode.vue'

const schema = {
  type: 'crud',
  columns: [
    { field: 'pageId', title: '配置ID' },
    { field: 'pageKey', title: '页面标识' },
    { field: 'remark', title: '页面说明' },
    { field: 'createBy', title: '创建者' },
    { field: 'createTime', title: '创建时间' },
    {
      field: 'operator',
      title: '操作',
      body: {
        type: 'space',
        body: [
          {
            type: 'link',
            level: 'primary',
            body: '修改',
            actionType: 'link',
            link: '/lowcode/operation?pageId=${pageId}',
            prePositionHook: (record) => {
              if (record) {
                window.localStorage.setItem('lowCodeRecordJson', JSON.stringify(record))
              }
            }
          },
          {
            type: 'link',
            level: 'danger',
            body: '删除',
            actionType: 'delete'
          }
        ]
      }
    }
  ],
  api: {
    url: '/system/page/list',
    responseData: '',
    responseAdaptor: (response) => {
      console.log(response)
      return response
    }
  },
  tableTop: [
    {
      type: 'button',
      reflectAttr: { type: 'primary' },
      actionType: 'link',
      body: '新增',
      link: '/lowcode/operation'
    }
  ]
}
</script>
